/**
 * localstorage封装
 */
import config from '../config'
export default {
    getItem(key) {
        return this.getStorage()[key]
    },
    setItem(key, value) {
        let storage = this.getStorage()
        storage[key] = value
        return window.localStorage.setItem(config.namespace, JSON.stringify(storage))
    },
    removeItem(key) {
        let storage = this.getStorage()
        delete storage[key]
        return window.localStorage.setItem(config.namespace, JSON.stringify(storage))
    },
    clearAll () {
        return window.localStorage.clear()
    },
    getStorage(){
        // console.log(1)
        return JSON.parse(window.localStorage.getItem(config.namespace)) || {}
    }
}
